package com.milling.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.milling.common.annotation.Log;
import com.milling.common.core.controller.BaseController;
import com.milling.common.core.domain.AjaxResult;
import com.milling.common.enums.BusinessType;
import com.milling.business.domain.WmsCellInfo;
import com.milling.business.service.IWmsCellInfoService;
import com.milling.common.utils.poi.ExcelUtil;
import com.milling.common.core.page.TableDataInfo;

/**
 * 货位设置Controller
 *
 * @author X
 * @date 2025-02-06
 */
@RestController
@RequestMapping("/business/cellinfo")
public class WmsCellInfoController extends BaseController
{
    @Autowired
    private IWmsCellInfoService wmsCellInfoService;

    /**
     * 查询货位设置列表
     */
    @PreAuthorize("@ss.hasPermi('business:cellinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsCellInfo wmsCellInfo)
    {
        startPage();
        List<WmsCellInfo> list = wmsCellInfoService.selectWmsCellInfoList(wmsCellInfo);
        return getDataTable(list);
    }

    /**
     * 导出货位设置列表
     */
    @PreAuthorize("@ss.hasPermi('business:cellinfo:export')")
    @Log(title = "货位设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsCellInfo wmsCellInfo)
    {
        List<WmsCellInfo> list = wmsCellInfoService.selectWmsCellInfoList(wmsCellInfo);
        ExcelUtil<WmsCellInfo> util = new ExcelUtil<WmsCellInfo>(WmsCellInfo.class);
        util.exportExcel(response, list, "货位设置数据");
    }

    /**
     * 获取货位设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:cellinfo:query')")
    @GetMapping(value = "/{cellId}")
    public AjaxResult getInfo(@PathVariable("cellId") Long cellId)
    {
        return success(wmsCellInfoService.selectWmsCellInfoByCellId(cellId));
    }

    /**
     * 新增货位设置
     */
    @PreAuthorize("@ss.hasPermi('business:cellinfo:add')")
    @Log(title = "货位设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsCellInfo wmsCellInfo)
    {
        return toAjax(wmsCellInfoService.insertWmsCellInfo(wmsCellInfo));
    }

    /**
     * 修改货位设置
     */
    @PreAuthorize("@ss.hasPermi('business:cellinfo:edit')")
    @Log(title = "货位设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsCellInfo wmsCellInfo)
    {
        return toAjax(wmsCellInfoService.updateWmsCellInfo(wmsCellInfo));
    }

    /**
     * 删除货位设置
     */
    @PreAuthorize("@ss.hasPermi('business:cellinfo:remove')")
    @Log(title = "货位设置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{cellIds}")
    public AjaxResult remove(@PathVariable Long[] cellIds)
    {
        return toAjax(wmsCellInfoService.deleteWmsCellInfoByCellIds(cellIds));
    }
}
